<?php
//for stock
ini_set("display_errors",1);
error_reporting(E_ALL);

try {
    $url = "http://api.dddadmin.com/StockService.svc?wsdl";
    $client = new SoapClient($url);
    echo '<pre>';
	
	//var_dump($client->__getFunctions());
	
	$shopid = "855001";
	$myKey	= "vkal29xcjs81lslc8qlxpgg63anxaqk2ixkskxm19m";
	
	$params['clientid'] = "855001";
	$params['psk'] = "vkal29xcjs81lslc8qlxpgg63anxaqk2ixkskxm19m";
	
	
	$articles = $client->GetWebshopArticles($params);
	//var_dump($articles);
	$strInfo = ($articles->GetWebshopArticlesResult);
	$arrInfo = json_decode($strInfo);
	
	$sizeInfo = array_chunk($arrInfo, 1000);
	$folder = 'product/';
	foreach($sizeInfo as $key=>$value){
		$file = fopen($folder. $key.'.txt', 'w');
		fwrite($file, serialize(array_values($value)));
		fclose($file);
	}
	
	echo "OK";
	/*
	$paramsstock['eans']	= array();
	$paramsstock['client']	= $shopid;
	$paramsstock['psk']		= $myKey;
	
	foreach($arrInfo as $key=>$value){
		
		$KatalogNumber 	= $value->KatalogNumber;
		$EdbNumber		= $value->EdbNumber;
		$SupplierName 	= $value->SupplierName;
		$ItemGroupName	= $value->ItemGroupName;
		$Supplier 		= $value->Supplier;
		$ItemGroup		= $value->ItemGroup;
		$Ean 			= $value->Ean;
		$Kparam1		= $value->Kparam1;
		$Kparam2 		= $value->Kparam2;
		$Kparam3		= $value->Kparam3;
		$Kparam4 		= $value->Kparam4;
		$Kparam5		= $value->Kparam5;
		$Vparam1 		= $value->Vparam1;
		$Vparam2		= $value->Vparam2;
		$Vparam3 		= $value->Vparam3;
		$Vparam4		= $value->Vparam4;
		$Vparam5 		= $value->Vparam5;
		$Qty			= $value->Qty;
		//$SalesPriceEach	= $value->SalesPriceEach;
		//$CostpriceEach	= $value->CostpriceEach;
		
		
		
	}
	
	*/
	
	echo '</pre>';
}
catch (SoapFault $exception) {
    echo $exception->getMessage();
}


?>
